$(function() {
    // ****************************************编辑用户
    let layer
    let form
    layui.use(['layer', 'form'], function() {
        layer = layui.layer
        form = layui.form


        let uurl = location.href
        let aa = uurl.split('?')
        let id = aa[1]
        let username = aa[2]
        let nickname = aa[3]
        let eamil = aa[4]
            //数据回填
        form.val('editForm', {
            id: id,
            username: username,
            nickname: nickname,
            eamil: eamil
        })
    })
    $('.layui-form').on('submit', function(e) {
        e.preventDefault()
        let data = form.val('editForm')

        $.ajax({
            url: '/admin/users',
            type: 'PUT',
            data: data,
            success: function(res) {
                console.log(res.message);
                location.href = '../../../user/user.html'
            }

        })
    })
})